﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Cooperation.Common
{
    public static class StringPlug
    {
        public static string ToJson(object o)
        {
            try
            {
                return Newtonsoft.Json.JavaScriptConvert.SerializeObject(o);
            }
            catch { }
            return string.Empty;
        }

        public static T ToObject<T>(string json)
        {
            try
            {
                return Newtonsoft.Json.JavaScriptConvert.DeserializeObject<T>(json);
            }
            catch { }
            return default(T);
        }
    }
}
